#!/usr/bin/python
# -*- coding: UTF-8 -*-
# author : bird.zhang@ximalaya.com

import random

import string


def gen_random_int(begin_close, end_open):
    """左开右闭"""
    range_ = end_open - begin_close
    return int(random.random() * range_ + begin_close)


# 所有数字
# DIGIT_BEGIN_CLOSE = 48
# DIGIT_END_OPEN = 58
# DIGIT_LIST = [chr(i) for i in range(DIGIT_BEGIN_CLOSE, DIGIT_END_OPEN)]
DIGIT_LIST = string.digits


def random_digit():
    return DIGIT_LIST[gen_random_int(0, len(DIGIT_LIST))]


# 所有小写字母
# LOWER_CHAR_BEGIN_CLOSE = 97
# LOWER_CHAR_END_OPEN = 123
# LOWER_CHAR_LIST = [chr(i) for i in range(LOWER_CHAR_BEGIN_CLOSE, LOWER_CHAR_END_OPEN)]


LOWER_CHAR_LIST = string.ascii_lowercase


def random_lower_char():
    return LOWER_CHAR_LIST[gen_random_int(0, len(LOWER_CHAR_LIST))]


# 所有大写字母
# UPPER_CHAR_BEGIN_CLOSE = 65
# UPPER_CHAR_END_OPEN = 91
# UPPER_CHAR_LIST = [chr(i) for i in range(UPPER_CHAR_BEGIN_CLOSE, UPPER_CHAR_END_OPEN)]

UPPER_CHAR_LIST = string.ascii_uppercase


def random_upper_char():
    return UPPER_CHAR_LIST[gen_random_int(0, len(UPPER_CHAR_LIST))]


SPECIAL_CHAR_LIST = """!@#$%^&*"""


def random_special_char():
    return SPECIAL_CHAR_LIST[gen_random_int(0, len(SPECIAL_CHAR_LIST))]


CHAR_LIST = DIGIT_LIST + LOWER_CHAR_LIST + UPPER_CHAR_LIST + SPECIAL_CHAR_LIST


def random_char():
    return CHAR_LIST[gen_random_int(0, len(CHAR_LIST))]
